package DP.chainOfResponsibility.women.handler;


import DP.chainOfResponsibility.women.womenBean.IWomen;

/**
 * @author msi
 * 有权处理的人员接口
 */
public abstract class Handler {

    public final static int FATHER_LEVEL_REQUEST=1;
    public final static int HUSBAND_LEVEL_REQUEST=2;
    public final static int SON_LEVEL_REQUEST=3;

    private int type=0;
    private Handler nextHandler;
    public Handler(int type){
        this.type=type;
    }

    public final void handleMessage(IWomen women){
        if(women.getType()==type){
            this.response(women);
        }else {
            if(this.nextHandler!=null){
                this.nextHandler.handleMessage(women);
            }else {
                System.out.println("没有找到具体的处理类");
            }
        }
    }

    public void setNext(Handler handler){
        this.nextHandler=handler;
    }

    protected abstract void response(IWomen women);
}
